//
//  HomeDataView.m
//  Feel_at_home
//
//  Created by dllo on 15/9/28.
//  Copyright © 2015年 Feel_at_home. All rights reserved.
//

#import "HomeDataView.h"

@implementation HomeDataView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        self.cover_image_url = [[UIImageView alloc]init];
        [self addSubview:self.cover_image_url];
        
        self.title = [[UILabel alloc]init];
        [self addSubview:self.title];
        
        self.share_msg = [[UILabel alloc]init];
        [self addSubview:self.share_msg];
        
    }
    return self;
}
- (void)layoutSubviews
{
    [super layoutSubviews];
    CGFloat w = self.frame.size.width;
    CGFloat h = self.frame.size.height;
    
    self.cover_image_url.frame = CGRectMake(0, 0, w, h*0.35);
    
    self.title.frame = CGRectMake(20, h*0.32, w - 20, h*0.2);
    [self.title setFont:[UIFont fontWithName:@"Helvetica-Bold" size:15]];
    [self.title setFont:[UIFont fontWithName:@"Helvetica-BoldOblique" size:21]];
//    self.title.textAlignment = 1;
    self.title.numberOfLines = 0;
    
    self.share_msg.frame = CGRectMake(5, h*0.45, w - 5, h*0.5);
    self.share_msg.font = [UIFont systemFontOfSize:18];
  
    self.share_msg.numberOfLines = 0;
   
}

+(CGFloat)heightWithText:(NSString *)text
{
    CGRect ret = [text boundingRectWithSize:CGSizeMake([UIScreen mainScreen].bounds.size.width/3*2, 0) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:17]} context:nil];
    return ret.size.height;
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
